#include "emfinfodockbuilder.h"
#include <QLineEdit>
#include <QVBoxLayout>

EmfInfoDockBuilder::EmfInfoDockBuilder()
{
}


QVector<QLayout *> EmfInfoDockBuilder::_prepareLabel(QPointF *info, int id)
{
    QVector<QLayout*> result;

    QLayout *headerLayout = new QVBoxLayout();
    QLabel * header = new QLabel("Emf #" + QString::number(id));
    QFont font = header->font();
    font.setBold(true);
    header->setFont(font);
    headerLayout->addWidget(header);
    result.push_back(headerLayout);

    QLayout *bodyLayout = new QHBoxLayout();
    QLineEdit *tEdit = new QLineEdit(QString::number((double)info->x()));
    tEdit->setReadOnly(true);
    tEdit->setAlignment(Qt::AlignCenter);

    QLineEdit *vEdit = new QLineEdit(QString::number((double)info->y()));
    vEdit->setReadOnly(true);
    vEdit->setAlignment(Qt::AlignCenter);

    bodyLayout->addWidget(new QLabel("t: "));
    bodyLayout->addWidget(tEdit);
    bodyLayout->addWidget(new QLabel(" v: "));
    bodyLayout->addWidget(vEdit);

    result.push_back(bodyLayout);

    return result;
}

QLayout * EmfInfoDockBuilder::build()
{
    return 0;
}

QLayout * EmfInfoDockBuilder::build(void* data)
{
    QPointF *point = (QPointF*)data;
    QVBoxLayout *layout = new QVBoxLayout();

    QVector<QLayout*> info = _prepareLabel(point, _globalId);
    for(int j=0; j<info.size(); j++)
        layout->addLayout(info[j]);
    return layout;
}
